<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateWithholdTableMybank extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('mybank_order_withhold_record', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('outTradeNo')->default(0)->comment('代扣业务订单号(外部流水号)');
            $table->string('outOrderNo', 128)->default('')->comment('OutOrderNo');
            $table->string('batchNo', 32)->default('')->comment('批处理号');
            $table->string('orderNo', 128)->default('')->comment('网商订单号');
            $table->string('operateNo', 128)->default('')->comment('当前网商操作单号');
            $table->string('scene', 32)->default('')
                  ->comment('业务场景：品牌协议代扣场景：PROTOCOL_WITHHOLD品牌协议代扣支持冻结场景：PROTOCOL_WITHHOLD_SUPPORT_FREEZE');
            $table->unsignedInteger('totalAmount')->default(0)->comment('交易金额（分）');
            $table->unsignedInteger('freezeAmount')->default(0)->comment('冻结部分出金（分）');
            $table->unsignedInteger('availableAmount')->default(0)->comment('可用部分金额（分）');
            $table->unsignedInteger('status')->default(0)->comment('状态 1 已提交申请 2 成功 3 失败');
            $table->unsignedInteger('submitDateTime')->default(0)->comment('交易提交时间');
            $table->unsignedInteger('finishDateTime')->default(0)->comment('交易完结时间');
            $table->string('currency', 3)->default('')->comment('币种');
            $table->string('payerId', 64)->default('')->comment('付款方商户号');
            $table->string('payerType', 16)->default('')->comment('付款方类型：MERCHANT');
            $table->string('payeeId', 64)->default('')->comment('收款方ID');
            $table->string('payeeType', 16)->default('')->comment('收款方类型 MERCHANT/PLATFORM');
            $table->string('memo', 128)->default('')->comment('备注（可填写订单描述信息）');
            $table->string('extInfo', 512)->default('')->comment('扩展信息');
            $table->string('errorCode', 32)->default('')->comment('FAIL 错误码');
            $table->string('errorDesc', 32)->default('')->comment('错误描述');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");

            $table->comment = '网商协议代扣记录表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('mybank_order_withhold_record');
    }
}
